package com.chandon.T01_lambda;

import com.chandon.common.Cv;
import com.chandon.common.Role;

import java.util.concurrent.Callable;

/**
 * ()->{}
 * <p>
 * ()->{System.out.println(1);}
 * <p>
 * ()->System.out.println(1)
 * <p>
 * ()->{return 100;}
 * <p>
 * ()->100
 * <p>
 * ()->null
 * <p>
 * (int x)->{return x+1;}
 * <p>
 * (int x)->x+1
 * <p>
 * (x)->x+1
 * <p>
 * x->x+1
 *
 * @author Dong
 * @version 1.0
 * @date 2021-04-14 0:28
 */

public class LambdaTest {
    public static void main(String[] args) throws Exception {

//        TestLambda1();
        Cv cv = Cv.builder().age(17).name("asamiyui").scope(10).build();
        Role role = Role.builder().cv(cv).name("yui").build();

/*
        CvDao cvDao = new CvDao() {
            @Override
            public void insert(Cv cv) {
                System.out.println(cv.getName());
            }
        };
*/
/*

        CvDao cvDao = (cv0)->{
            System.out.println(cv0.getName());
        };

*/
/*

        CvDao cvDao = (Cv cv0) -> System.out.println(cv0.getName());
        cvDao.insert(cv);

*/

//   -------------------------------------------------------------
/*

        CharacterDao characterDao = new CharacterDao() {
            @Override
            public String getCv(Role role) {
                return role.getCv().getName();
            }
        };

*/
/*


        CharacterDao characterDao =(a)->{return a.getCv().getName();};
        CharacterDao characterDao = (a) -> a.getCv();

*/


//        Cv cv1 = characterDao.getCv(role);
//        System.out.println(cv1);


    }


    private static void TestLambda1() throws Exception {

        Callable<String> c1 = new Callable<String>() {
            @Override
            public String call() throws Exception {
                return "asami";
            }
        };
        System.out.println(c1.call());


        Callable<String> c2 = () -> {
            return "asamiyui";
        };
        System.out.println(c2.call());


        Callable<String> c3 = () -> "asamiyui";
        System.out.println(c3.call());
    }


}
